var beiMiCommon = require("BeiMiCommon");
cc.Class({
    extends: beiMiCommon,

    properties: {
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
        //预制资源
       
        club: {
            default: null,
            type: cc.Prefab
        },
        more: {
            default: null,
            type: cc.Prefab
        },
        record: {
            default: null,
            type: cc.Prefab
        },
        share: {
            default: null,
            type: cc.Prefab
        },
        shop: {
            default: null,
            type: cc.Prefab
        },
        kefu: {
            default: null,
            type: cc.Prefab
        },
        rules: {
            default: null,
            type: cc.Prefab
        },
        setting: {
            default: null,
            type: cc.Prefab
        },
        menuTab:'play',
        menu:{
            default:null,
            type:cc.Node
        },
        playTab:'shuangkou',
        play:{
            default:null,
            type:cc.Node
        },
        notice:{
            default:null,
            type:cc.Node
        },
        exitGame:{
            default:null,
            type:cc.Prefab
        }
    },


    // use this for initialization
    onLoad: function () {
        this.initTab(this.menu.children,this.menuTab);
        this.initTab(this.play.children,this.playTab);
        this.notice.active=false;
    },
    onClubClick:function(){
        cc.beimi.openwin = cc.instantiate(this.club) ;
        cc.beimi.openwin.parent = this.root();
    },
    onMoreClick:function(){
        cc.beimi.openwin = cc.instantiate(this.more) ;
        cc.beimi.openwin.parent = this.root();
    },
    onRecordClick:function(){
        cc.beimi.openwin = cc.instantiate(this.record) ;
        cc.beimi.openwin.parent = this.root();
    },
    onShareClick:function(){
        cc.beimi.openwin = cc.instantiate(this.share) ;
        cc.beimi.openwin.parent = this.root();
    },
    onShopClick:function(){
        cc.beimi.openwin = cc.instantiate(this.shop) ;
        cc.beimi.openwin.parent = this.root();
    },
    onKefuClick:function(){
        cc.beimi.openwin2 = cc.instantiate(this.kefu) ;
        cc.beimi.openwin2.parent = this.root();
    },
    onRulesClick:function(){
        cc.beimi.openwin = cc.instantiate(this.rules) ;
        cc.beimi.openwin.parent = this.root();
    },
    onSettingClick:function(){
        cc.beimi.openwin = cc.instantiate(this.setting) ;
        cc.beimi.openwin.parent = this.root();
    },
    initTab:function(tabs,activeTab){
        tabs.map(function(item){
            if(activeTab==item.name){
                item.getChildByName('back').active=true;
            }else{
                item.getChildByName('back').active=false;
            }
        })
    },
    menuTabClick:function(e){
        if(this.menuTab!=e.currentTarget.name){
           this.menuTab=e.currentTarget.name;
           this.initTab(this.menu.children,this.menuTab);
           if(e.currentTarget.name=='notice'){
               this.play.active=false;
               this.notice.active=true;
           }else{
            this.play.active=true;
            this.notice.active=false;
           }
        }
    },
    playTabClick:function(e, type){
        cc.beimi.roomType = type;
        if(this.playTab!=e.currentTarget.name){
           this.playTab=e.currentTarget.name;
           this.initTab(this.play.children,this.playTab);
        }
    },
    onExitGameClick:function(){
        cc.beimi.openwin = cc.instantiate(this.exitGame) ;
        cc.beimi.openwin.parent = this.root();
    },
    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
